/**
 * 个人中心--我的产品
 */
var userCenterOrderController={
    initData:function(){
        $.ajax({
            type: "post",
            url: "/custom/order/data/list",
//                cache:false,
//                async:false,
            dataType: "json",
            // data:data,
            success: function(data){
                if(data.length>0){
                    $("#nodatatip2").hide();
                    $("#productlist").html("");
                    userCenterOrderController.buildData(data);
                }else{
                    $("#nodatatip2").show();
                }
            },
            failure:function (result) {
                console.log("加载产品信息失败");
            }
        });
    },
    buildData:function(data){
        $.each(data, function(i,n){
            $("#productlist").append(userCenterOrderController.showHtmlData(n));
        });
    },
    showHtmlData:function(obj){
        var picpath = '/static/custom/images/sp_img.png';
        if(obj.picFirstId){
            picpath = '/fileDownLoad/showFile/'+obj.picFirstId;
        }

       var datahtml = '<li>'
         +' <div class="sp-dataBox">'
           +'   <div class="sp-top">'
           +'  <button type="button" class="close" data-toggle="modal" data-target="#myModal" title="删除"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'
           +'  </div>'
           +' <a href="">'
           +'<img src="'+picpath+'" class="userImg" alt="" style="width:268px;height: 188px"/>'
           +' <h3>'+obj.productName+'</h3>'
           +'</a>'
           +' <p class="am-text-gray">订单编号：'+obj.no+'</p>'
           +'<p class="am-text-gray">产品编号：'+obj.productCode+'</p>'
           +'<p class="am-text-gray">成交时间：'+new Date(obj.createTime).format("yyyy-MM-dd hh:mm")+'</p>'
           +'<div class="charge">'
           +'<a href="" class="btn btn-line btn-primary">使用</a>'
           +'</div>'
           +'</div>'
           +' </li>';
       return datahtml;
    }
};

$(function(){
    userCenterOrderController.initData();
});
